(module tests mzscheme
  
  (provide tests-for-run tests-for-check)
  ;;;;;;;;;;;;;;;; tests ;;;;;;;;;;;;;;;;
  
  (define tests-for-run
    '(
      
      (test-cdr-exp "cdr (-(1,2) -(1,3) 3)" (-2 3))
      
      (test-car-exp "car (-(2,1) 2 3)" 1)
      
      (add-typed-test-1!  "list(11,22,33)"
                          (11 22 33))
      
      (add-typed-test-2!      "list(list(11,22),list(33))"
                              ((11 22) (33)))
      
      
      (add-typed-test-3! 
       "list(11,false)"
       (11 #f))
      
      (add-typed-test-4! 
       "list(list(11,22),list(false))"
       ((11 22) (#f)))
      
      ;(add-typed-test! 
      ; "proc(x : int, y : listof int) cons(x,y)"
      ; dontrun)
      
      (add-typed-test-5! 
       "let f = proc(x : int, y : listof int) cons(x,y)
       g = proc(x : bool, y : listof bool) cons(x,y)
       true = zero?(0)
   in if car((g true emptylist[bool])) 
      then car(cdr(cons(2,(f 3 emptylist[int]))))
      else 4"
       3)
      
      (add-typed-test-6! 
       "emptylist[bool]"
       ())
      
      (add-typed-test-7! 
       "(proc(x : int) let y = emptylist[int] in cons(x,y) 
    33)"
       (33))
      
      (add-typed-test-8!
       "(proc (x : listof int) car(x)
 list(11,22,33))"
       11)
      
      (add-typed-test-9!  
       "letrec
 listof bool map1 (f : (int -> bool), x : listof int) 
   = if null?(x) then emptylist[bool]
                 else cons( (f car(x)),
                            (map1 f cdr(x)) )
in (map1
     proc (x : int) zero?(x)
     list(22,0,33,44,0))"
                          (0 1 0 0 1))
      
      (add-typed-test-10!  "
let map1 = proc (f : (int -> bool), x : listof int) 
            letrec 
             listof bool innerloop (x : listof int) 
              = if null?(x) 
                 then emptylist[bool]
                 else cons( (f car(x)),
                            (innerloop cdr(x)) )
             in (innerloop x)
in (map1
     proc (x : int) zero?(x)
     list(22,0,33,44,0))"
                           (0 1 0 0 1))
      
      ))
  
  (define tests-for-check
    '(
      
     ;; tests from run-tests:
      (add-typed-test-1!  "list(11,22,33)"
                          (listof int) )
      
      (check-cdr-exp "cdr (1 2 3)" (listof int))
      
      (check-car-exp "car (1 2 3)" int)
      
      (add-typed-test-2! 
       "list(list(11,22),list(33))"
       (listof (listof int)))
      
      ;      (add-typed-test-3! 
      ;       "list(11,false)"
      ;       error )
      
      (add-typed-test-4! 
       "list(list(11,22),list(false))"
       error )
      
      (add-typed-test-5! 
       "proc(x : int, y : listof int) cons(x,y)"
       (int * (listof int) -> (listof int)) )
      
      (add-typed-test-6! 
       "let f = proc(x : int, y : listof int) cons(x,y)
       g = proc(x : bool, y : listof bool) cons(x,y)
       true = zero?(0)
   in if car((g true emptylist[bool])) 
      then car(cdr(cons(2,(f 3 emptylist[int]))))
      else 4"
       3)
      
      (add-typed-test-7! 
       "emptylist[bool]"
       '(listof bool) )
      
      (add-typed-test-8! 
       "(proc(x : int) let y = emptylist[int] in cons(x,y) 
    33)"
       (listof int) )
      
      (add-typed-test-9!  
       "(proc (x : listof int) car(x)
 list(11,22,33))"
       ;11)
       int)
      
      (add-typed-test-10! "
letrec
 listof bool map1 (f : (int -> bool), x : listof int) 
   = if null?(x) then emptylist[bool]
                 else cons( (f car(x)),
                            (map1 f cdr(x)) )
in (map1
     proc (x : int) zero?(x)
     list(22,0,33,44,0))"
                          (listof bool) )
      
      (add-typed-test-11!  "
let map1 = proc (f : (int -> bool), x : listof int) 
            letrec 
             listof bool innerloop (x : listof int) 
              = if null?(x) 
                 then emptylist[bool]
                 else cons( (f car(x)),
                            (innerloop cdr(x)) )
             in (innerloop x)
in (map1
     proc (x : int) zero?(x)
     list(22,0,33,44,0))"
                           (listof bool) )      
      
      ))
  )